package com.sc.nft.admin.rpc;

import com.sc.nft.admin.request.ExportDaoTeamHoldCollectionRequest;
import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.admin.request.TeamHoldCountRequest;
import com.sc.nft.dto.TeamHoldCollectionVO;
import com.sc.nft.entity.vo.DaoTeamHoldCollectionVO;
import com.sc.nft.service.UserCollectionService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/rpc/userCollection")
@Api(tags = "后台藏品RPC接口")
public class UserCollectionRpc {

    private final UserCollectionService userCollectionService;

    @PostMapping(value = "/getTeamHoldCollectioncCuntByCollectionId", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取团对的持有某个藏品数量", notes = "获取团对的持有某个藏品数量", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiIgnore
    public Result<List<TeamHoldCollectionVO>> getTeamHoldCollectioncCountByCollectionId(@Valid @RequestBody TeamHoldCountRequest request) {
        return Result.success(userCollectionService.getTeamHoldCollectioncCountByCollectionId(request.getCollectionId(), request.getUserTel()));
    }

    @PostMapping(value = "/exportDaoTeamHoldCollection", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "导出网体持仓", notes = "导出网体持仓", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiIgnore
    public Result<Boolean> exportDaoTeamHoldCollection(@Valid @RequestBody ExportDaoTeamHoldCollectionRequest request) {
        return Result.success(userCollectionService.exportDaoTeamHoldCollection(request.getDaoId(), request.getDaoUserId(), request.getUserTel(), request.getCollectionId()));
    }

    @PostMapping(value = "/downloadDaoTeamHoldCollection", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "下载网体持仓", notes = "下载网体持仓", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiIgnore
    public Result<List<DaoTeamHoldCollectionVO>> downloadDaoTeamHoldCollection(@Valid @RequestBody IdRequest request) {
        return Result.success(userCollectionService.downloadDaoTeamHoldCollection(request.getId()));
    }

}
